"""notes URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.9/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Add an import:  from blog import urls as blog_urls
    2. Import the include() function: from django.conf.urls import url, include
    3. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
"""
from django.conf.urls import url
from django.contrib import admin
from blog import views
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import include
from django.contrib.auth.decorators import login_required

urlpatterns = [
	url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT}),
	url(r"^media/(?P<path>.*)$", "django.views.static.serve", {"document_root": settings.MEDIA_ROOT,}),
	url(r'^$', views.post_list, name='post_list'),
	url(r'^first_page/', views.first_page, name='first_page'),
	url(r'^admin/', admin.site.urls),
	url(r'^ckeditor/', include('ckeditor_uploader.urls')),
	# url(r'^search/', login_required(views.MySearchView()), name='haystack_search'),
	url(r'^create/$', login_required(views.PostCreateView.as_view(template_name_suffix="login")), name='post_create'),
	url(r'^(?P<pk>\d+)/delete/$', login_required(views.PostDeleteView.as_view(template_name_suffix='login')),
	    name='post_delete'),
	url(r'^(?P<pk>\d+)/edit/$', login_required(views.PostUpdateView.as_view(template_name_suffix='login')),
	    name='post_edit'),
	url(r'^(?P<pk>\d+)/post_detail/$', views.detail, name='post_detail'),
	url(r'^tag/(?P<tag_name>.*)/$', views.post_list, name='post_list_by_tag'),
	url(r'^login/$', 'django.contrib.auth.views.login', name='login'),
	url(r'^logout/$', 'django.contrib.auth.views.logout', name='logout'),
	url(r'^search/(?P<query>.*)$', views.mysearch, name='mysearch'),
]
